package com.njxxted.activiti.modules.process.extend.controller;

import com.njxxted.activiti.common.response.ResponseVo;
import com.njxxted.activiti.common.util.PageUtil;
import com.njxxted.activiti.modules.base.controller.BaseController;
import com.njxxted.activiti.modules.process.extend.entity.ExtendActUrgentEntity;
import com.njxxted.activiti.modules.process.extend.entity.req.ExtendActUrgentReqEntity;
import com.njxxted.activiti.modules.process.extend.service.ExtendActUrgentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 描述：流程催办前端控制器
 * <p>
 * 作者：Ostrich Hu
 * 时间：2019/11/25 16:42 星期一
 */
@Api(tags = "流程催办")
@RestController
@RequestMapping(value = "/act/rest/extend/urgent")
public class ExtendActUrgentController extends BaseController {

    @Resource
    private ExtendActUrgentService extendActUrgentService;

    @ApiOperation(value = "查询", notes = "分页查询")
    @GetMapping("/")
    public ResponseVo list(ExtendActUrgentReqEntity param) {
        PageUtil<ExtendActUrgentEntity> actOpinionList = extendActUrgentService.queryList(param);
        return ResponseVo.ok(actOpinionList);
    }

    @ApiOperation(value = "查询", notes = "根据主键id查询")
    @GetMapping("/{id}")
    public ResponseVo info(@PathVariable("id") String id) {
        ExtendActUrgentEntity actOpinionEntity = extendActUrgentService.queryObject(id);
        return ResponseVo.ok(actOpinionEntity);
    }

    @ApiOperation(value = "保存或修改", notes = "保存或修改")
    @PostMapping("/")
    public ResponseVo saveOrUpdate(ExtendActUrgentReqEntity param) {
        int i = extendActUrgentService.saveOrUpdate(param);
        if (i > 0)
            return ResponseVo.ok();
        else
            return ResponseVo.error();
    }

    @ApiOperation(value = "删除", notes = "删除")
    @DeleteMapping("/")
    public ResponseVo delete(@RequestParam("ids") String[] ids) {
        int i = extendActUrgentService.deleteBatch(ids);
        if (i > 0)
            return ResponseVo.ok();
        else
            return ResponseVo.error();
    }


}
